package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Qualityview;
import com.ruoyi.system.service.IQualityviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 质量管理视图Controller
 *
 * @author ruoyi
 * @date 2024-05-22
 */
@RestController
@RequestMapping("/system/qualityview")
public class QualityviewController extends BaseController
{
    @Autowired
    private IQualityviewService qualityviewService;

    /**
     * 查询质量管理视图列表
     */
    @PreAuthorize("@ss.hasPermi('system:qualityview:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qualityview qualityview)
    {
        startPage();
        List<Qualityview> list = qualityviewService.selectQualityviewList(qualityview);
        return getDataTable(list);
    }

    /**
     * 导出质量管理视图列表
     */
    @PreAuthorize("@ss.hasPermi('system:qualityview:export')")
    @Log(title = "质量管理视图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Qualityview qualityview)
    {
        List<Qualityview> list = qualityviewService.selectQualityviewList(qualityview);
        ExcelUtil<Qualityview> util = new ExcelUtil<Qualityview>(Qualityview.class);
        util.exportExcel(response, list, "质量管理视图数据");
    }

    /**
     * 获取质量管理视图详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:qualityview:query')")
    @GetMapping(value = "/{projectName}")
    public AjaxResult getInfo(@PathVariable("projectName") String projectName)
    {
        return success(qualityviewService.selectQualityviewByProjectName(projectName));
    }

    /**
     * 新增质量管理视图
     */
    @PreAuthorize("@ss.hasPermi('system:qualityview:add')")
    @Log(title = "质量管理视图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qualityview qualityview)
    {
        return toAjax(qualityviewService.insertQualityview(qualityview));
    }

    /**
     * 修改质量管理视图
     */
    @PreAuthorize("@ss.hasPermi('system:qualityview:edit')")
    @Log(title = "质量管理视图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qualityview qualityview)
    {
        return toAjax(qualityviewService.updateQualityview(qualityview));
    }

    /**
     * 删除质量管理视图
     */
    @PreAuthorize("@ss.hasPermi('system:qualityview:remove')")
    @Log(title = "质量管理视图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectNames}")
    public AjaxResult remove(@PathVariable String[] projectNames)
    {
        return toAjax(qualityviewService.deleteQualityviewByProjectNames(projectNames));
    }
}
